package com.paas.kafka;

import com.plat.paas.core.PaasUtilsContextHolder;
import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class KafkaServiceStart {

	//private static final Logger log = LoggerFactory.getLogger(KafkaServiceStart.class);
	private static final Logger log = Logger.getLogger(KafkaServiceStart.class);
    public static final String SERVICE_CONTEXT_CONFIG_XML = "classpath*:service-context-config.xml";
    public static final String PAAS_CONTEXT_CONFIG_XML = "classpath*:applicationContext.xml";

	public static void init() {
        @SuppressWarnings("resource")
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[] { PAAS_CONTEXT_CONFIG_XML });

        context.registerShutdownHook();
        context.start();
        
        PaasUtilsContextHolder.setContext(context);
	}
	public static void main(String[] args) throws InterruptedException {

        long t1 = System.currentTimeMillis(), t2 = 0L;

		try {
			KafkaServiceStart.init();
		} catch (Exception e) {
			e.printStackTrace();
            System.exit(0);
		}
        t2 = System.currentTimeMillis();
        
        log.info("KafkaServiceStart 启动完成时间 : "+ (t2 - t1) + "ms");
        
        /*
        while (true) {
            try {
                Thread.currentThread();
                Thread.sleep(3L);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        */
	}
}
